package javaDemo06;

public class Dice_2 {
    public static void main(String[] args) {
        int win = 0;
        int lose = 0;
        for(int i = 1;i <= 1000;i++){
            if(Dice() == true){
                win++;
            }else{
                lose++;
            }
        }
        System.out.println("赢了" + win);
        System.out.println("输了" + lose);
    }
    public static boolean Dice() {
        boolean vo = true;
        boolean c = true;
        while (c) {
            int a = (int) (Math.random() * 6 + 1);
            int b = (int) (Math.random() * 6 + 1);
            if (a + b == 2 || a + b == 3 || a + b == 12) {
//                System.out.println("第一颗骰子为" + a);
//                System.out.println("第二颗骰子为" + b);
//                System.out.println("你输了");
                c = false;
                vo = false;

            } else if (a + b == 7 || a + b == 11) {
//                System.out.println("第一颗骰子为" + a);
//                System.out.println("第二颗骰子为" + b);
//                System.out.println("你赢了");
                c = false;
                vo = true;

            } else {
                int test = a + b;
//                System.out.println("第一颗骰子为" + a);
//                System.out.println("第二颗骰子为" + b);
//                System.out.println("point is " + test);
                boolean f = true;
                while (f) {
                    int e = (int) (Math.random() * 6 + 1);
                    int r = (int) (Math.random() * 6 + 1);
                    int test1 = e + r;
                    if (test == test1) {
//                        System.out.println("第二轮开始");
//                        System.out.println("第一颗骰子为" + e);
//                        System.out.println("第二颗骰子为" + r);
//                        System.out.println("你赢了");
                        vo = true;
                        f = false;

                    } else if (test1 == 7) {
//                        System.out.println("第二轮开始");
//                        System.out.println("第一颗骰子为" + e);
//                        System.out.println("第二颗骰子为" + r);
//                        System.out.println("你输了");
                        f = false;
                        vo = false;

                    }
                }
                c = false;
            }

        }
        return vo;
    }
}
